<?php

namespace Admin\SystemBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class UserType extends AbstractType
{
        /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
		$builder->add('username', 'text', array(
    			'required'  => true,
    			'max_length' => 25,    			
    			'attr' => array(
    					'class' => 'form_input',
    					'placeholder' => 'Login',
    					'size' => 40,
    			),    			
		));
    	
    	$builder->add('password', 'repeated', array(
    			'type' => 'password',
    			'first_options'  => array('label' => 'Senha'),
    			'second_options' => array('label' => 'Confirmar Senha'),
    			'required'  => true,
    			'max_length' => 64,
    			'attr' => array(
    				'class' => 'form-input',
    				'size' => 40,    				
    			),    			
    	));
    	
    	$builder->add('nome', 'text', array(
    			'max_length' => 50,
    			'attr' => array(
    					'class' => 'form_input',
    					'size' => 40,
    					'placeholder' => 'Nome',
    			),
    	));
    	 
    	$builder->add('email', 'email', array(
    			'required'  => true,
    			'max_length' => 100,
    			'attr' => array(
    					'class' => 'form_input',
    					'size' => 40,
    					'placeholder' => 'E-mail',
    			),
    	));
    	    	
    	
    	$builder->add('profile', 'entity', array(
    			'class' => 'AdminSystemBundle:Role',
    			'property' => 'name',
    			'multiple'  => false,
    	));
    	
    	//selectbox ativo/inativo
    	$builder->add('isActive', 'choice', array(
    			'choices'   => array(
    					'1' 	  => 'Ativo',
    					'0' 	  => 'Inativo',
    			),
    			'required'  => true,
    	));
    	
    	$builder->add('id', "hidden", array('required'  => false));
    }
    
    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Admin\SystemBundle\Entity\User'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'admin_systembundle_usuario';
    }
}
